package com.itfreer.setting.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.itfreer.core.security.UserInfoEntity;
import com.itfreer.setting.R;
import com.itfreer.core.security.SecurityService;
import com.itfreer.ui.activity.BaseActivity;
import com.itfreer.ui.base.TextView;

/**
 * 密码修改
 */
public class PasswordActivity extends BaseActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setNavigationBarColor();

        setContentView(R.layout.activity_password);

        // 返回
        TextView me =(TextView)findViewById(R.id.setting_password_back);
        me.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                finish();
            }
        });

        final EditText opText =(EditText)findViewById(R.id.setting_password_op);
        final EditText npText =(EditText)findViewById(R.id.setting_password_np);

        Button okButton =(Button)findViewById(R.id.setting_password_ok);
        okButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // 处理用户登录，并更新配置
                SecurityService.instance.init(new SecurityService.UserListener() {
                    @Override
                    public void onSuccess(UserInfoEntity user) {
                    }

                    @Override
                    public void onGetJwt() {
                        SecurityService.instance.setPassword(opText.getText().toString(), npText.getText().toString(),
                                npText.getText().toString(), PasswordActivity.this);
                    }

                    @Override
                    public void onFail() {

                    }
                });
            }
        });
    }
}
